/**
 *
 * 加载进度条
 * @author 
 *
 */
class LoadBar extends egret.DisplayObjectContainer {
    
    private bm: egret.Bitmap;
    
    private barl: egret.Bitmap;
    private prol: egret.Sprite;

	public constructor() {
        super()
	}
	
	private label:egret.TextField
	public start(){
        this.prol = new egret.Sprite();
        this.addChild(this.prol);

        var bm:egret.Bitmap = Util.createBitmapByName("loadbar_bg_png")
		bm.x = (egret.MainContext.instance.stage.stageWidth - 400)/2
		bm.y = 238
        this.prol.addChild(bm);
        //182 18
        var barl:egret.Bitmap = Util.createBitmapByName("loadbar_top_png");
		barl.x = bm.x
        barl.y = bm.y;
        this.prol.addChild(barl);
		this.barl = barl

		var label:egret.TextField = new egret.TextField;
		label.text = 'Loading';
		label.textColor = 0xFFFFFF;
		label.size = 20;
		label.y = 260;
		label.x = (egret.MainContext.instance.stage.stageWidth - label.width)/2;
		label.textAlign = egret.HorizontalAlign.CENTER;
		this.prol.addChild(label);

		this.label = label
	}
    
	/*
	 * 设置加载进度
	 */ 
	public setProgress(current, total){
        this.barl.width=current/total*400;
		this.label.text = Math.floor(current*100/total) + '%'
	}
}
